import java.util.HashMap;
import java.util.Map;
class NameCache
{
    public String getName(String input)
    {
        if(!nameCache.containsKey(input))
        {
            nameCache.put(input, sequence++);
            return "(" + nameCache.get(input) + ") " + input;
        }
        else
        {
            return "(" + nameCache.get(input) + ")";
        }
    }
    private  Map<String, Integer> nameCache = new HashMap<String, Integer>();
    private  Integer sequence = 1;
}